<?php
	defined('_JEXEC') or die('Restricted access');
	require_once(CUTEENGINE_BASE_COMPONENTS_PATH."base_display_component_class.php");
	require_once(CUTEENGINE_PARTS_PATH."form_part/form_part.php");
    //
    // t_component_overlap

    //
	class t_component_overlap extends t_base_display_component
	{	
		// property
		// public		
		// C
        public $content_loader = null;
		// L
		const language_position_last = 1;
        
        // M
		const main_query_component_bound_component_id = "bound_component_id";
		const main_query_component_closing_method_type = "closing_method_type";
		const main_query_component_return_field_name = "return_field_name";
        // S
		const specific_parameters_position_bound_component_id = 1;
        const specific_parameters_position_closing_method_type = 2;
		const specific_parameters_position_return_field_name = 3;
        const specific_parameters_position_last = 4;
		// method
		// protected
		//C
		protected function create_tags_structure()
		{
			global $g_javascript_namespace;            


            // javascript
            //
            if (! $this->main_tag)
			{
                
				$this->main_tag = new t_base_tag(t_base_tag_type::btt_div,$this->name);

				$local_header_script_generator = $this->main_tag->header_script_generator;
				//
                $this->main_tag->include_child_str = true;
                $local_header_script_generator->add_style_sheet_property("#$this->name","display","inline-block");
				$local_header_script_generator->add_style_sheet_property("#$this->name",'position','relative');
				$local_header_script_generator->add_style_sheet_property("#$this->name",'background-color','cyan');
				$local_header_script_generator->add_style_sheet_property("#$this->name",'border','1px solid blue');
				$local_header_script_generator->add_style_sheet_property("#$this->name",'padding','10px');
				$this->main_tag->set_editing_tags(true);
                //
				$this->compute_tags_structure();
   
                /* */
                
			}
		}
        // G
		public function get_language_position_last()
        {
            return self::language_position_last;
        }
		
        protected function get_specific_parameters_position_last()
        {
            return self::specific_parameters_position_last;
        }
        static function get_help_specific_parameter($a_index)
		{
			$local_return = 'NO HELP AVAILABLE';
			/*switch ($a_index) 
            {
                case self::specific_parameters_position_:
					$local_return = '';
				break;                
			}*/
			return $local_return;
		}
        static function get_default_specific_parameter($a_index)
		{
			$local_return = '';
			//echo "a_index: $a_index<br>";
			switch ($a_index) 
            {
                /*case self::specific_parameters_position_:
					$local_return = 'TRUE';
				break;                */
			}
			return $local_return;
		}	

		// I
		protected function initialize_query_parameters()
		{
		   // echo "new_query_parameter<br>";
            $this->new_query_parameter(
				t_cuteengine_component::main_query_parameter_name,
				self::main_query_component_bound_component_id,
				t_cuteengine_component::main_query_field_name_specific_parameters,
				self::specific_parameters_position_bound_component_id);	
            $this->new_query_parameter(
				t_cuteengine_component::main_query_parameter_name,
				self::main_query_component_closing_method_type,
				t_cuteengine_component::main_query_field_name_specific_parameters,
				self::specific_parameters_position_closing_method_type);	
            $this->new_query_parameter(
				t_cuteengine_component::main_query_parameter_name,
				self::main_query_component_return_field_name,
				t_cuteengine_component::main_query_field_name_specific_parameters,
				self::specific_parameters_position_return_field_name);	
		}
		// public
		public function __construct($a_cuteengine_component,$a_query_parameter) 
		{
			global $g_javascript_namespace;
			global $g_cuteengine;
			$this->use_log = true;
			$this->content_loader = new t_content_loader($g_javascript_namespace,$this);
			$this->content_loader->initialize_parameter('undefined',
				'undefined','undefined','undefined',
				'undefined','undefined',false);
			
            parent::__construct($a_cuteengine_component,$a_query_parameter);
			//echo "this->get_bound_component_id(): ".$this->get_bound_component_id()."<br>";
			$this->content_loader->component_to_log = $this->get_log_tag_name();
			
		}	
		// C
		public function create_internal_parts()
        {
			global $g_database_namespace;
            parent::create_internal_parts();
			//echo __METHOD__  . "<br>";
			// LOG FIELD
			$local_log_field = '';
			if ($this->use_log)
			{
				$local_log_field = "|t_field_label|".parent::get_log_tag_name()."|-3|";
			} 
			//echo "this->get_bound_component_id(): ".$this->get_bound_component_id()."<br>";
			// MAIN FORM	
            $local_part = $this->add_new_part(-1,1,t_form_part,'@'.$this->name.'_part@@@',"",
				//fields
				"@|t_field_overlap|".$this->get_start_field_name()."|".t_form_part::fields_position_form."|".$this->get_bound_component_id()."|".$this->get_closing_method_type()."|".$this->get_return_field_name().
				$local_log_field.
				"|@",
				// action 1
				""
                ,1);  
        }
		
		//D
	/*	public function display_component()
		{
			parent::display_component();
		}*/
		// E
		public function execute_component_action()
		{
			$local_function = parent::execute_component_action();
            if ($local_function)
			{
				$this->$local_function();
            }
			else
			{
				 
			}
			//echo "argomento: ".$this->url_argument(self::main_url_argument_import_file_name);
			//$this->parse_source();
		}

        public function get_bound_component_id()
        {
            return $this->get_main_query_parameter_value(self::main_query_component_bound_component_id); 
        }
        public function get_closing_method_type()
        {
            return $this->get_main_query_parameter_value(self::main_query_component_closing_method_type); 
        }
        public function get_return_field_name()
        {
            return $this->get_main_query_parameter_value(self::main_query_component_return_field_name); 
        }
        public function get_start_field_name()
        {
            return $this->name . "_overlap"; 
			//return self::main_query_component_button_label;
        }
        
	}
?>